/*--------------------------------------------------------------*
 * Creat Date: 2015/7/20 										*
 * Modify    : 
 *                                     
 *--------------------------------------------------------------*/

#ifndef _AT24C04_H_
#define _AT24C04_H_

#include "i2cdevice.h"

#ifdef	__cplusplus
extern "C" {
#endif

#define AT24C02                    0
#define AT24C04                    0
#define AT24C256                   0
#define AT24C512                   0
#define AT24C1024                  1

/*---------------------------------------------------------------*
 * ADDR_TYPE:
 * [0]: indicate sda bytes ,0 - one byte,1 two byte
 * [3-1]:indicate inter-sla 
 * [7-4]:must be 0
 *---------------------------------------------------------------*/

#if AT24C02 > 0
#define EEP_PAGE_SIZE              8
#define EEP_PAGE_MASK              0x07	   //Page Addr :3bits
#define EEP_ADDR_SIZE              0x100
#define EEP_SUBA_SIZE              0x100
#define EEP_SUBA_MASK              0xFF
#define EEP_ADDR_TYPE              0       //1 byte       

#elif AT24C04 > 0
#define EEP_PAGE_SIZE              16
#define EEP_PAGE_MASK              0x0F	   //Page Addr :4bits
#define EEP_ADDR_SIZE              0x200
#define EEP_SUBA_SIZE              0x100
#define EEP_SUBA_MASK              0xFF
#define EEP_ADDR_TYPE              2       //1+.x byte       

#elif AT24C256 > 0
#define EEP_PAGE_SIZE              64
#define EEP_PAGE_MASK              0x3F	   //Page Addr :6bits
#define EEP_ADDR_SIZE              0x8000
#define EEP_SUBA_SIZE              0x8000
#define EEP_SUBA_MASK              0x7FFF
#define EEP_ADDR_TYPE              1       //2 byte   

#elif AT24C512 > 0
#define EEP_PAGE_SIZE              128
#define EEP_PAGE_MASK              0x7F	   //Page Addr :6bits
#define EEP_ADDR_SIZE              0x10000
#define EEP_SUBA_SIZE              0x10000
#define EEP_SUBA_MASK              0xFFFF
#define EEP_ADDR_TYPE              1       //2 byte  

#elif AT24C1024 > 0
#define EEP_PAGE_SIZE              128
#define EEP_PAGE_MASK              0x7F	   //Page Addr :6bits
#define EEP_ADDR_SIZE              0x20000
#define EEP_SUBA_SIZE              0x10000
#define EEP_SUBA_MASK              0xFFFF
#define EEP_ADDR_TYPE              3       //2 byte 
#endif  

#define EEP_INTER_SLA_MASK         0x0E
#define EEP_CHIP_ADDR              0xA0    //



uint8_t at24Write(uint32_t DataAdd,uint16_t Len,uint8_t  *Rsc);
uint8_t at24Read(uint32_t DataAdd,uint16_t Len,uint8_t *Des);

#ifdef	__cplusplus
}
#endif

#endif

